home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 157_01 / qed.h < prev    next >
Text File  |  1987-10-10  |  11KB  |  311 lines

  1. /*  VERSION 0007  (DATE: 29/04/87)  (TIME: 12:41)  */
  2. /*
  3.     e screen editor  (qed)
  4.  
  5.     (C) G. Nigel Gilbert, MICROLOGY, 1981
  6.     licensed for private non-profitmaking use 1983
  7.     
  8.     August-December 1981
  9.  
  10.     Modified: Aug-Dec     1984:  BDS-C 'e' to 'qe'             (J.W.Haefner)
  11.               March        1985:  BDS-C 'qe' to DeSmet-C 'qed' (J.W.Haefner)
  12.  
  13.     FILE: qed.h
  14.  
  15.     PURPOSE: standard header file, #included in all function files
  16.         (NB e does NOT require "bdscio.h")
  17.  
  18. */
  19.  
  20. #define VERSION "4.6b/QED:1.23"
  21.  
  22. #define STKSPACE 1536            /*space for the stack*/
  23. #define SECSIZ 128                /*file buffer definitions*/
  24. #define NSECTS 16
  25. #define IOBUFSIZ (NSECTS * SECSIZ + 6 )
  26. #define FILELEN 60                /*max length of file name*/
  27. #define PATHLEN 24                /*max length of path*/
  28.  
  29. #define JBUFSIZE 6                /*size of buffer required for longjumps*/
  30.  
  31. #define LLIM 255                /*max length of a line*/
  32. #define FLIM 80                    /*max length of find/alter string*/
  33.  
  34. #define FAIL -1
  35. #define DFAIL 0xff                /*DeSmet read fail flag for returning char*/
  36. #define NULL 0
  37. #define YES 1
  38. #define NO 0
  39. #define FALSE 0
  40. #define TRUE 1
  41. #define PREV -2
  42.  
  43. #define DOS2 (YES)
  44. #define CPM (NO)
  45. #define IBMPC (YES)
  46.  
  47. #if IBMPC
  48. #define NOTIBMPC (NO)
  49. #else
  50. #define NOTIBMPC (YES)
  51. #endif
  52.  
  53. /* -- compile flags for major editor options -- */
  54. #define    SCRNDIMMD (NO)    /*yes==>highlite current line,no==>all brite */
  55. #define WWRAP (YES)        /*compile word wrap code*/
  56. #define PRINTALL (YES)    /*send all chars to printer*/
  57. #define VRSNNUM (YES)    /*put version number at file top on save*/
  58. #define VRSNDATE (YES)  /*put version date/time w/ version num*/
  59.  
  60. #define NOCLOCK (NO)    /*NO ==> have a clock*/
  61. #define VRSNLEN 56        /*length of version string*/
  62.  
  63. #define SWIDTH 79        /*screen size*/
  64. #define SHEIGHT 23
  65. #define OFFWIDTH 20        /*horizontal scroll increment*/
  66. #define PAGEOVERLAP 4    /*overlap between pages with UP,DOWN-PAGE*/
  67. #define HELPLINES 8        /*top line number when help menu is on display */
  68. #define GOTOLEN 6        /* approx len of contrl line */
  69.  
  70. #define FNPOS 8            /*status line - position of file name*/
  71. #define LNPOS 23        /*position of line number*/
  72. #define EMPOS 32        /*position of error message*/
  73. #define WAITPOS 32        /*position of cursor when searching/reading*/
  74. #define REPPOS 50        /*position of "Replace?" message*/
  75.  
  76. #define BACKSP 0x08        /*backspace*/
  77. /*#define ENDFILE 0x1a*/    /*CP/M end of text file mark */
  78. #define ENDFILE 0xff    /*for MSDOS 2.x and DeSmet-C, 28.iv.87*/
  79. #define CTRL 0x1f        /*last control char.*/
  80. #define PARBIT 0x80        /*parity bit used as a flag by testkey() */
  81. #define NKEYS 32        /*number of key codes*/
  82.  
  83.     /*internal key codes (recommended key assignments in brackets)*/
  84.  
  85. #define LEADIN 0        /*lead in chararacter to key codes -
  86.                 ignored, but following key code parity set*/
  87. #define DOWNKEY 1        /*cursor down */
  88. #define UPKEY   2        /*cursor up*/
  89. #define LEFTKEY 3        /*cursor left*/
  90. #define RIGHTKEY 4        /*cursor right*/
  91. #define RIGHTWKEY 5        /*cursor right one word (D) */
  92. #define LEFTWKEY 6        /*cursor left one word (S) */
  93. #define EOLKEY 7        /*cursor to end of line (E) */
  94. #define BOLKEY 8        /*cursor to beginning of line (B) */
  95. #define UPPAGE 9        /*scroll up a page (W) */
  96. #define DOWNPAGE 10        /*scroll down a page (Z) */
  97. #define BOFKEY 11        /*cursor to beginning of file (U) */
  98. #define HOMEKEY 12        /*cursor to end of file (HOME) */
  99. #define DELLEFT 13        /*delete char to left of cursor (DEL) */
  100. #define DELRIGHT 14        /*delete char under cursor (G) */
  101. #define DELLNKEY 15        /*delete cursor line (Y) */
  102. #define DELWDKEY 16        /*delete word to right of cursor (T) */
  103. #define JUMPKEY 17        /*jump to (X) */
  104. #define CRSTILL 18        /*insert newline after cursor (N) */
  105. #define QWIKKEY 19        /*quit (Q) */
  106. #define SCRLDNKEY 20    /*edit and file context (C) */
  107. #define TOPSCRKEY 21    /*find (F) */
  108. #define BOTSCRKEY 22    /*alter (A) */
  109. #define BLOCKKEY 23        /*block operations (O) */
  110. #define SCRLUPKEY 24    /*read a file (P) */
  111. #define REPKEY 25        /*repeat last find/alter (R) */
  112. /*#define HELPKEY 26*/        /*display help menu (V) */
  113. #define UNDELINE 26        /*restore deleteted line below cursor*/
  114. #define OOPSKEY 27        /*restore unedited line (\) */
  115. #define TAB 28            /*tab (I)*/
  116. #define RETRIEVE 29        /*retrieve last name etc entered here (R)*/
  117. #define CR 30            /*return (M)*/
  118. #define ESCKEY 31        /*the magic escape key (ESC)*/
  119.  
  120.     /* key codes + 0x80 (PARBIT) used in scanning strings of ctrl chars */
  121. #define LEFTKEY_P    131
  122. #define    DELLEFT_P    141
  123. #define RETRIEVE_P    157
  124. #define    CR_P        158
  125. #define    ESCKEY_P    159
  126.  
  127. #define BRIDIM '|'        /*char placed in e's message strings to start/stop
  128.                 dim (half-intensity) display */
  129.  
  130.         /* CP/M and MSDOS bdos function codes */
  131.  
  132. #define DOSINT 0x21
  133.  
  134. #define RESET 0
  135. #define CONIN 0x01
  136. #define CONOUT 0x02
  137. #define LSTOUT 0x05
  138. #define DIRIO 0x06
  139. #define IOBYTE 0x07
  140. #define SETIOBYTE 0x08
  141. #define PRINTS 0x09
  142. #define READBUF 0x0A
  143. #define CONSTAT 0x0B
  144. #define VERNO 0x0C
  145. #define RESETDSK 0x0D
  146. #define SELDSK 0x0E
  147. #define OPEN 0x0F
  148. #define CLOSEF 0x10
  149. #define SEARCH1 0x11
  150. #define SEARCHN 0x12
  151. #define DELETEF 0x13
  152. #define READ 0x14
  153. #define WRITE 0x15
  154. #define MAKE 0x16
  155. #define RENAME 0x17
  156. #define LOGINV 0x18
  157. #define CURDSK 0x19
  158. #define SETDMA 0x1A
  159. #define PROTECT 0x1C
  160. #define GETROV 0x1d
  161. #define DSKPARAMS 0x1F
  162. #define READR 0x21
  163. #define WRITER 0x22
  164. #define FSIZE 0x23
  165. #define SETRR 0x24
  166. #define RESETDRV 0x25
  167. #define FREESP    0x36
  168. #define SETDIR    0x3b
  169. #define GETDIR  0x47
  170. #define FIND1    0x4e
  171. #define FINDN    0x4f
  172.  
  173. #define MAXSLOTS 1024        /*virtual memory constants*/
  174. #define MAXMEMSLOTS 64        /*36 for 64k TPA (CP/M816); old=20*/
  175. #define PAGESIZE 1024
  176. #define PAGESECTS (PAGESIZE/SECSIZ)
  177.  
  178. #define FREE 0
  179. #define INUSE 1
  180. #define NOTAVAIL -1
  181. #define MAXINT 32767
  182. #define NOFILE (MAXINT)
  183. #define ABSOLUTE 0
  184. #define UNKNOWN (MAXINT)
  185.  
  186. #define sint int            /*carry-over from 'e', just in case*/
  187.  
  188. struct addr {
  189.     int page;
  190.     int moffset;
  191.     } *tp;                    /*address of text of each line*/
  192.  
  193. int allocp;                    /*location of next free in newpage */
  194. int pageloc[MAXSLOTS];        /*current location of each page*/
  195. int usage[MAXMEMSLOTS];        /*records usage of in memory slots*/
  196. char *slotaddr[MAXMEMSLOTS];    /*memory addr of start of each in memory slot*/
  197. char dskslots[MAXSLOTS];    /*is disk slot free*/
  198. int slotsinmem;                /*max no. of slots available in memory*/
  199. int tppages;                /*no. of pages used to hold text pointers*/
  200. int newpage;                /*page no of page being filled with text*/
  201. char *npaddr;                /*base of slot holding newpage*/
  202. int clock;                    /*counter for least recently used paging*/
  203.  
  204. int pagefd;                    /*file descriptor of paging file*/
  205. char pagingfile[FILELEN];    /*name of paging file*/
  206. char pagingdisk;            /*disk to put paging file on*/
  207.  
  208. int curdsk;                    /*currently logged in (default) disk*/
  209. char bakpath[PATHLEN];        /*default path for backup*/
  210.  
  211. char mainmenu[JBUFSIZE];    /*for emergency longjump*/
  212. int goodline;                /*line number we know we can display */
  213. unsigned errold[4];            /*temp store for CP/M's error jump addrs*/
  214. char dskerr[JBUFSIZE];        /*for bdos disk error traps*/
  215.  
  216. char textbuf[IOBUFSIZ];        /*io buffer for file being edited*/
  217.  
  218. int cursorx, cursory;        /*current position of cursor*/
  219. char tran[NKEYS];            /*translation table from external to internal
  220.                                 key codes*/
  221. char isdim;                    /*last char was in dim*/
  222. int lastl;                    /*number of last line of text*/
  223. int lastread;                /*last line actually read to date*/
  224. char goteof;                /*true when eof of file being edited*/
  225. char changed;                /*true if file has been modified*/
  226. int cline;                    /*current line*/
  227. char text[LLIM];            /*buffer for current line of text*/
  228. char textb[LLIM];            /*buffer for last deleted line*/
  229. int charn;                    /*position of current char in current line*/
  230. char altered;                /*if YES, current line has been altered by edits*/
  231.  
  232. int pfirst, plast;            /*top and bottom line displayed on screen*/
  233. int topline;                /*first line on screen for text*/
  234. int offset;                    /*first col. to display on screen*/
  235. int lastoff;                /*offset last time resetcursor() was called*/
  236. char blankedmess;            /*message area has been blanked, not overwritten*/
  237.  
  238. char inbuf[20];                /*input buffer for typeahead*/
  239. int  inbufp;                /*pointer to next char in inbuf*/
  240.  
  241.